<?php

/**
 * +------ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER * ---------+
 * +----------------------------------------------------------------------------+
 * | PHPKiisf - Keep It in Simple Framework										|
 * | Version 1.0																|
 * | Copyright (C) <2013>  Mario Cezzare <mcezzare@gmail.com>					|
 * | Blog: http://mcezzare.blogspot.com.br										|
 * |																			|
 * | This program is part of PHPKiisf, and is free software: you can			|
 * | redistribute it and/or modify it under the terms of the GNU 				|
 * | General Public License as published by										|
 * | the Free Software Foundation, either version 3 of the License, or			|
 * | (at your option) any later version.										|
 * |																			|
 * | This program is distributed in the hope that it will be useful,			|
 * | but WITHOUT ANY WARRANTY; without even the implied warranty of				|
 * | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the				|
 * | GNU General Public License for more details.								|
 * | You should have received a copy of the GNU General Public License			|
 * | along with this program.  If not, see <http://www.gnu.org/licenses/>.		|
 * +----------------------------------------------------------------------------+
 * | Author : <Mario Cezzare Angelicola Chiodi> <mcezzare@gmail.com>			|
 * +----------------------------------------------------------------------------+
 * | Contributors																|
 * |																			|
 * +----------------------------------------------------------------------------+
 *
 * Common functions to project, but too simple to create an object
 *
 * @package	includes
 * @access	public
 * @since	2013-03-08
 * @author	Mario Cezzare <mcezzare@gmail.com>
 */

/**
 * Dump the array between tags pre
 *
 * @param object $object object or array to display
 * @param type $options
 * @param type $mode default P => print_r | D => var_dump
 */
function print_pre( $object , $options = null , $mode = "P" ) {
	$output = "<pre style=\"border:solid 1px #EA9C5C;  padding:3px; color:#000000; background-color:#ededed \">" ;

	$mode == "P" ? $output .= print_r( $object ) : "" ;
	$mode == "D" ? $output .= var_dump( $object ) : "" ;

	$output .= "</pre>" ;
	$output .= "<hr size=\"1\" width=\"100%\">" ;

	print $output ;
}

/**
 *
 * @param type $message
 * @param type $options
 */
function display_user_message( $message , $options = null ) {
	if ( isset( $message ) && is_string( $message ) ) {
		print (sprintf( "<br> %s <br>" , $message ) ) ;
	}
}

/**
 *
 * @param type $var
 * @param type $method
 * @param type $can_be_null
 */
function read_var( $var , $method = "P" , $strip_tags = true , $can_be_null = false ) {
//		$methods = array(
//		"P" => sprintf("_POST[%s]" $var) ,
//		"G" => sprintf("_GET[%s]" , $var) ,
//		);
	$internal_var = null ;
	if ( $var == null && !isset( $var ) ) {
		return false ;
	}
	if ( $strip_tags ) {
		if ( $method == "P" ) {
			if ( isset( $_POST[$var] ) ) {
				$internal_var = strip_tags( $_POST[$var] ) ;
			}
		}
		if ( $method == "G" ) {
			if ( isset( $_GET[$var] ) ) {
				$internal_var = strip_tags( $_GET[$var] ) ;
			}
		}

		return $internal_var ;
	} else {
		if ( $method == "P" ) {
			if ( isset( $_POST[$var] ) ) {
				$internal_var = $_POST[$var] ;
			}
		}
		if ( $method == "G" ) {
			if ( isset( $_GET[$var] ) ) {
				$internal_var = $_GET[$var] ;
			}
		}
		return $internal_var ;
	}
}

?>